

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>20.13. smtpd — SMTP Server &mdash; Python v2.7.8 documentation</title>
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '2.7.8',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/sidebar.js"></script>
    <link rel="search" type="application/opensearchdescription+xml"
          title="Search within Python v2.7.8 documentation"
          href="../_static/opensearch.xml"/>
    <link rel="author" title="About these documents" href="../about.html" />
    <link rel="copyright" title="Copyright" href="../copyright.html" />
    <link rel="top" title="Python v2.7.8 documentation" href="../index.html" />
    <link rel="up" title="20. Internet Protocols and Support" href="internet.html" />
    <link rel="next" title="20.14. telnetlib — Telnet client" href="telnetlib.html" />
    <link rel="prev" title="20.12. smtplib — SMTP protocol client" href="smtplib.html" />
    <link rel="shortcut icon" type="image/png" href="../_static/py.png" />
    <script type="text/javascript" src="../_static/copybutton.js"></script>
    
 
    

  </head>
  <body>  
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="telnetlib.html" title="20.14. telnetlib — Telnet client"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="smtplib.html" title="20.12. smtplib — SMTP protocol client"
             accesskey="P">previous</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="http://www.python.org/">Python</a> &raquo;</li>
        <li>
          <a href="../index.html">Python v2.7.8 documentation</a> &raquo;
        </li>

          <li><a href="index.html" >The Python Standard Library</a> &raquo;</li>
          <li><a href="internet.html" accesskey="U">20. Internet Protocols and Support</a> &raquo;</li> 
      </ul>
    </div>    

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-smtpd">
<span id="smtpd-smtp-server"></span><h1>20.13. <a class="reference internal" href="#module-smtpd" title="smtpd: A SMTP server implementation in Python."><tt class="xref py py-mod docutils literal"><span class="pre">smtpd</span></tt></a> &#8212; SMTP Server<a class="headerlink" href="#module-smtpd" title="Permalink to this headline">¶</a></h1>
<p><strong>Source code:</strong> <a class="reference external" href="http://hg.python.org/cpython/file/2.7/Lib/smtpd.py">Lib/smtpd.py</a></p>
<hr class="docutils" />
<p>This module offers several classes to implement SMTP servers.  One is a generic
do-nothing implementation, which can be overridden, while the other two offer
specific mail-sending strategies.</p>
<div class="section" id="smtpserver-objects">
<h2>20.13.1. SMTPServer Objects<a class="headerlink" href="#smtpserver-objects" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="smtpd.SMTPServer">
<em class="property">class </em><tt class="descclassname">smtpd.</tt><tt class="descname">SMTPServer</tt><big>(</big><em>localaddr</em>, <em>remoteaddr</em><big>)</big><a class="headerlink" href="#smtpd.SMTPServer" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new <a class="reference internal" href="#smtpd.SMTPServer" title="smtpd.SMTPServer"><tt class="xref py py-class docutils literal"><span class="pre">SMTPServer</span></tt></a> object, which binds to local address
<em>localaddr</em>.  It will treat <em>remoteaddr</em> as an upstream SMTP relayer.  It
inherits from <a class="reference internal" href="asyncore.html#asyncore.dispatcher" title="asyncore.dispatcher"><tt class="xref py py-class docutils literal"><span class="pre">asyncore.dispatcher</span></tt></a>, and so will insert itself into
<a class="reference internal" href="asyncore.html#module-asyncore" title="asyncore: A base class for developing asynchronous socket handling services."><tt class="xref py py-mod docutils literal"><span class="pre">asyncore</span></tt></a>&#8216;s event loop on instantiation.</p>
<dl class="method">
<dt id="smtpd.SMTPServer.process_message">
<tt class="descname">process_message</tt><big>(</big><em>peer</em>, <em>mailfrom</em>, <em>rcpttos</em>, <em>data</em><big>)</big><a class="headerlink" href="#smtpd.SMTPServer.process_message" title="Permalink to this definition">¶</a></dt>
<dd><p>Raise <a class="reference internal" href="exceptions.html#exceptions.NotImplementedError" title="exceptions.NotImplementedError"><tt class="xref py py-exc docutils literal"><span class="pre">NotImplementedError</span></tt></a> exception. Override this in subclasses to
do something useful with this message. Whatever was passed in the
constructor as <em>remoteaddr</em> will be available as the <tt class="xref py py-attr docutils literal"><span class="pre">_remoteaddr</span></tt>
attribute. <em>peer</em> is the remote host&#8217;s address, <em>mailfrom</em> is the envelope
originator, <em>rcpttos</em> are the envelope recipients and <em>data</em> is a string
containing the contents of the e-mail (which should be in <span class="target" id="index-0"></span><a class="rfc reference external" href="http://tools.ietf.org/html/rfc2822.html"><strong>RFC 2822</strong></a>
format).</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="debuggingserver-objects">
<h2>20.13.2. DebuggingServer Objects<a class="headerlink" href="#debuggingserver-objects" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="smtpd.DebuggingServer">
<em class="property">class </em><tt class="descclassname">smtpd.</tt><tt class="descname">DebuggingServer</tt><big>(</big><em>localaddr</em>, <em>remoteaddr</em><big>)</big><a class="headerlink" href="#smtpd.DebuggingServer" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new debugging server.  Arguments are as per <a class="reference internal" href="#smtpd.SMTPServer" title="smtpd.SMTPServer"><tt class="xref py py-class docutils literal"><span class="pre">SMTPServer</span></tt></a>.
Messages will be discarded, and printed on stdout.</p>
</dd></dl>

</div>
<div class="section" id="pureproxy-objects">
<h2>20.13.3. PureProxy Objects<a class="headerlink" href="#pureproxy-objects" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="smtpd.PureProxy">
<em class="property">class </em><tt class="descclassname">smtpd.</tt><tt class="descname">PureProxy</tt><big>(</big><em>localaddr</em>, <em>remoteaddr</em><big>)</big><a class="headerlink" href="#smtpd.PureProxy" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new pure proxy server. Arguments are as per <a class="reference internal" href="#smtpd.SMTPServer" title="smtpd.SMTPServer"><tt class="xref py py-class docutils literal"><span class="pre">SMTPServer</span></tt></a>.
Everything will be relayed to <em>remoteaddr</em>.  Note that running this has a good
chance to make you into an open relay, so please be careful.</p>
</dd></dl>

</div>
<div class="section" id="mailmanproxy-objects">
<h2>20.13.4. MailmanProxy Objects<a class="headerlink" href="#mailmanproxy-objects" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="smtpd.MailmanProxy">
<em class="property">class </em><tt class="descclassname">smtpd.</tt><tt class="descname">MailmanProxy</tt><big>(</big><em>localaddr</em>, <em>remoteaddr</em><big>)</big><a class="headerlink" href="#smtpd.MailmanProxy" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new pure proxy server. Arguments are as per <a class="reference internal" href="#smtpd.SMTPServer" title="smtpd.SMTPServer"><tt class="xref py py-class docutils literal"><span class="pre">SMTPServer</span></tt></a>.
Everything will be relayed to <em>remoteaddr</em>, unless local mailman configurations
knows about an address, in which case it will be handled via mailman.  Note that
running this has a good chance to make you into an open relay, so please be
careful.</p>
</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../contents.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">20.13. <tt class="docutils literal"><span class="pre">smtpd</span></tt> &#8212; SMTP Server</a><ul>
<li><a class="reference internal" href="#smtpserver-objects">20.13.1. SMTPServer Objects</a></li>
<li><a class="reference internal" href="#debuggingserver-objects">20.13.2. DebuggingServer Objects</a></li>
<li><a class="reference internal" href="#pureproxy-objects">20.13.3. PureProxy Objects</a></li>
<li><a class="reference internal" href="#mailmanproxy-objects">20.13.4. MailmanProxy Objects</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="smtplib.html"
                        title="previous chapter">20.12. <tt class="docutils literal docutils literal"><span class="pre">smtplib</span></tt> &#8212; SMTP protocol client</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="telnetlib.html"
                        title="next chapter">20.14. <tt class="docutils literal"><span class="pre">telnetlib</span></tt> &#8212; Telnet client</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
  <li><a href="../bugs.html">Report a Bug</a></li>
  <li><a href="../_sources/library/smtpd.txt"
         rel="nofollow">Show Source</a></li>
</ul>

<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" size="18" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>  
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="telnetlib.html" title="20.14. telnetlib — Telnet client"
             >next</a> |</li>
        <li class="right" >
          <a href="smtplib.html" title="20.12. smtplib — SMTP protocol client"
             >previous</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="http://www.python.org/">Python</a> &raquo;</li>
        <li>
          <a href="../index.html">Python v2.7.8 documentation</a> &raquo;
        </li>

          <li><a href="index.html" >The Python Standard Library</a> &raquo;</li>
          <li><a href="internet.html" >20. Internet Protocols and Support</a> &raquo;</li> 
      </ul>
    </div>  
    <div class="footer">
    &copy; <a href="../copyright.html">Copyright</a> 1990-2014, Python Software Foundation.
    <br />
    The Python Software Foundation is a non-profit corporation.
    <a href="http://www.python.org/psf/donations/">Please donate.</a>
    <br />
    Last updated on Jun 29, 2014.
    <a href="../bugs.html">Found a bug</a>?
    <br />
    Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
    </div>

  </body>
</html>